package com.cimp.dao.iqy;

import com.cimp.domain.iqy.Virtual;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * [简要描述]:
 * [详细描述]:
 *
 * @author huojinhao
 * @date 2018/11/23
 */

public interface IqyVirtualDao {

    @Insert("insert into t_iqy_virtual (tag,region,url,content) values(#{tag},#{region},#{url},#{content})")
    void insertVirtual(Virtual virtual);

    @Update("update t_iqy_virtual set tag=#{tag},region=#{region},url=#{url},content=#{content} where id=#{id}")
    void updateVirtual(Virtual virtual);

    @Select("select * from t_iqy_virtual order by id desc")
    List<Virtual> listVirtual();

    @Delete("delete from t_iqy_virtual where id=#{id}")
    void deleteVirtual(Integer id);

    @Update("update t_iqy_virtual set state=#{state} where id=#{id}")
    void updateVirtualState(Virtual virtual);

    @Update("update t_iqy_virtual set state=0 where id!=#{id} and region=#{region}")
    void inActiveOtherVirtualState(Virtual virtual);

    @Select("select content from t_iqy_virtual where region=#{region} and state=1")
    String queryVirtualContent(@Param("region") String region);
}
